package com.demo.petshop.controller;

import com.demo.petshop.entity.VideoLikes;
import com.demo.petshop.service.VideoLikesService;
import com.mybatisflex.core.paginate.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 *  控制层。
 *
 * @author lenovo
 * @since 2025-06-11
 */
@RestController
@RequestMapping("/videoLikes")
public class VideoLikesController {

    @Autowired
    private VideoLikesService videoLikesService;


    @PostMapping("save")
    public boolean save(@RequestBody VideoLikes videoLikes) {
        return videoLikesService.save(videoLikes);
    }


    @DeleteMapping("remove/{id}")
    public boolean remove(@PathVariable Serializable id) {
        return videoLikesService.removeById(id);
    }


    @PutMapping("update")
    public boolean update(@RequestBody VideoLikes videoLikes) {
        return videoLikesService.updateById(videoLikes);
    }


    @GetMapping("list")
    public List<VideoLikes> list() {
        return videoLikesService.list();
    }


    @GetMapping("getInfo/{id}")
    public VideoLikes getInfo(@PathVariable Serializable id) {
        return videoLikesService.getById(id);
    }


    @GetMapping("page")
    public Page<VideoLikes> page(Page<VideoLikes> page) {
        return videoLikesService.page(page);
    }


    @PostMapping("like")
    public Object like(@RequestParam Integer videoId) {
        return videoLikesService.like(videoId);
    }

    @PostMapping("unlike")
    public Object unlike(@RequestParam Integer videoId) {
        return videoLikesService.unlike(videoId);
    }

    @GetMapping("checkLike")
    public Object checkLike(@RequestParam Integer videoId) {
        return videoLikesService.checkLike(videoId);
    }
}
